<?php
/**
 * @desc 热销商品
 * @author kevin.wang
 * @date 2015-01-01 12:00:00
 */
class HotGoods extends Base
{
	//数据表
	protected $table = 'pert_hotsale';
	protected $gtable = 'pert_goods';
	//查询热销商品列表
	public function getHotSaleList()  
    {
		 $table = $this->table;
		 $gtable = $this->gtable;
		 $filed = "a.`hotsale_id`,a.`hotsale_keyword`,a.`goods_id`,b.`goods_sn`,b.`goods_name`,b.`price`,b.`unit`,b.`detail_image`,a.`hot_url`,a.`category`";
		 $sql = "select {$filed} from `{$table}` as a,`{$gtable}` as b where a.`goods_id` = b.`goods_id` and a.`delete_flag` = 0 and a.`is_show` = 0 order by a.`sort` desc, a.`raw_add_time` desc";
		 return $this->select_table($sql, array());
    }
	//热销商品按国家分类
	public function hotSaleCategory(array $hotSale)
	{
		$result = array();
		if(empty($hotSale)){
			return $result;
		}
		foreach($hotSale as $key=>$value){
			$value['hotsale_keyword'] = $this->hotWords($value['hotsale_keyword']);
			$result[$value['category']][] = $value;
		}
		return $result;
	}
}
